class Solution {
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int ret = 0;
        for (int i = 1; i < timeSeries.size(); ++i) 
        {
            ret += min(duration, timeSeries[i] - timeSeries[i - 1]);
        }
        return ret + duration; // 最后一次中毒持续时间加上
    }
};